#include <iostream>
#define N 100

using namespace std;

int main( )
{
    char a[N],a1[N],a2[N];
    int i=0,j=0,k,n;

    cout<<"enter the string of a1"<<endl;
    gets(a1);
    cout<<"enter the string of a2"<<endl;
    scanf("%s",a2);

    while(a1[i]!='\0') i++;
    while(a2[j]!='\0') j++;

    n=i>j?j:i;

    for(k=0;k<n;k++)
    {
        if(a1[k]==a2[k])  a[k]=a1[k];
        else break;
    }

    a[k]='\0';

    puts(a);

    cin>>i;
    return 0;
}